﻿using PHMEE.EnergyEfficiency;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using Volo.Abp;

namespace PHMEE
{
    public static class PhmeeConst
    {
        public const string SignalRReceiveMessage = "ReceiveMessage";

        /// <summary>
        /// Excel 2007 及更高版本
        /// </summary>
        public const string Mimexlsx = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

        /// <summary>
        /// Excel 97-2003
        /// </summary>
        public const string Mimexls = "application/vnd.ms-excel";

        public const string LanguageEn = "en";

        public const string BaseInfoTypeLocalizedVessel = "VesselEnum";

        public const string BaseInfoTypeLocalizedVesselFlowmetorMode = "VesselFlowMeterModeEnum";

        public const string BaseInfoTypeLocalizedUnit = "UnitEnum";

        public const string BaseInfoTypeLocalizedEquipment = "EquipmentEnum";

        public const string BaseInfoTypeLocalizedEquipmentRotationMode = "RotationModeEnum";

        public const string BaseInfoTypeLocalizedEquipmentConnectMode = "ConnectModeEnum";

        public const string BaseInfoTypeLocalizedEquipmentSupportFlexibilityMode = "SupportFlexibilityModeEnum";

        public const string BaseInfoTypeLocalizedEquipmentBearingType = "BearingTypeEnum";

        public const string BaseInfoTypeLocalizedComponent = "ComponentEnum";

        public const string BaseInfoTypeLocalizedPoint = "PointTypeEnum";

        public const string BaseInfoTypeLocalizedPointCategory = "PointCategoryEnum";

        public const string BaseInfoTypeLocalizedPointPosition = "PointPositionEnum";

        public const string BaseInfoTypeLocalizedPointDirection = "PointDirectionEnum";

        public const string BaseInfoTypeLocalizedPointDiagnosisAlg = "DiagnosisAlgEnum";

        public const string BaseInfoTagLocalized = "BaseInfoTagEnum";


        /// <summary>
        /// 获取完整数据库名称
        /// </summary>
        /// <param name="dbPrefix">数据库前缀</param>
        /// <param name="vesselId">船舶id</param>
        /// <returns></returns>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public static string GetDbName(DbPrefixEnum dbPrefix, Guid vesselId)
        {
            return dbPrefix switch
            {
                DbPrefixEnum.Ee => $"ee_{vesselId:N}",
                DbPrefixEnum.Ams => $"ams_{vesselId:N}",
                DbPrefixEnum.Vb => $"vb_{vesselId:N}",
                _ => throw new ArgumentOutOfRangeException(nameof(dbPrefix), dbPrefix, "未知的 TDengine 数据库前缀")
            };
        }

        /// <summary>
        /// 通用字段类
        /// </summary>
        public static class CommonFields
        {
            /// <summary>
            /// ts时间
            /// </summary>
            public const string ts = "ts";
        }

        #region TD超级表
        /// <summary>
        /// TD超级表
        /// </summary>
        public static class TdSuperTables
        {
            /// <summary>
            /// 流量计
            /// </summary>
            public const string Flowmeter = "flowmeter";

            /// <summary>
            /// Gps
            /// </summary>
            public const string Gps = "gps";

            /// <summary>
            /// 轴功率计
            /// </summary>
            public const string ShaftPowerMeter = "shaft_power_meter";

            /// <summary>
            /// ams-模拟量
            /// </summary>
            public const string AmsAnalog = "analog";

            /// <summary>
            /// ams-开关量
            /// </summary>
            public const string AmsDigital = "digital";
        }
        #endregion


        #region 流量计属性

        [SuperTable(TdSuperTables.Flowmeter)]
        public static class TdFlowmeter
        {
            public const string ts = CommonFields.ts;

            /// <summary>
            /// 瞬时油耗
            /// </summary>
            public const string Instant = "instant";

            /// <summary>
            ///  分钟油耗 
            /// </summary>
            public const string OilValue = "oil_value";

            /// <summary>
            /// 流量计显示的总油耗
            /// </summary>
            public const string TotalValue = "total_value";

            /// <summary>
            /// 温度
            /// </summary>
            public const string Temperature = "temperature";

            /// <summary>
            /// 密度
            /// </summary>
            public const string Density = "density";

            /// <summary>
            /// 油品
            /// </summary>
            public const string FuelType = "fuel_type";
        }
        #endregion

        #region Gps属性

        [SuperTable(TdSuperTables.Gps)]
        public static class TdGps
        {
            public const string ts = CommonFields.ts;

            /// <summary>
            /// 经度
            /// </summary>
            public const string Longitude = "longitude";

            /// <summary>
            /// 纬度
            /// </summary>
            public const string Latitude = "latitude";

            /// <summary>
            /// 对地航速
            /// </summary>
            public const string GroundSpeed = "ground_speed";

            /// <summary>
            /// 每分钟航行距离
            /// </summary>
            public const string Distance = "distance";
        }
        #endregion

        #region 轴功率计属性

        [SuperTable(TdSuperTables.ShaftPowerMeter)]
        public static class TdShaftPowerMeter
        {
            public const string ts = CommonFields.ts;

            /// <summary>
            /// 轴转速
            /// </summary>
            public const string Speed = "speed";

            /// <summary>
            /// 轴功率
            /// </summary>
            public const string Power = "power";

            /// <summary>
            /// 轴扭矩
            /// </summary>
            public const string Torque = "torque";

            /// <summary>
            /// 总转数
            /// </summary>
            public const string TotalRevs = "total_revs";

            /// <summary>
            /// 总能量
            /// </summary>
            public const string TotalEng = "total_eng";
        }
        #endregion

        #region Ams模拟量
        [SuperTable(TdSuperTables.AmsAnalog)]
        public static class TdAmsAnalog
        {
            public const string ts = CommonFields.ts;
            /// <summary>
            /// 模拟量数值
            /// </summary>
            public const string Value = "v";
            /// <summary>
            /// 模拟量单位
            /// </summary>
            public const string Unit = "u";
        }
        #endregion

        #region Ams开关量
        [SuperTable(TdSuperTables.AmsDigital)]
        public static class TdAmsDigital
        {
            public const string ts = CommonFields.ts;
            /// <summary>
            /// 报警值（1:正常，2:报警）
            /// </summary>
            public const string Value = "v";
        }
        #endregion

    }
}
